import java.io.IOException;
import java.net.ServerSocket;


public class ServerThread extends Thread{

	
	private ServerSocket socket;
	private boolean state = true;
	
	Simulator sim;

    public ServerThread(int port, Simulator current) {
    	super("ServerThread");
    	
    	this.sim = current;
    	
    	try {
			this.socket = new ServerSocket(port);
		} catch (IOException e) {
			System.out.println("Algum erro");
			e.printStackTrace();
		}
    }

    public void run() {
    	
		try {
			
			while (state)
			
				new ClientThread(this.socket.accept(), this.sim).start();
				
			this.socket.close();
			 
		} catch (IOException e) {
			System.out.println("ERRO");
			e.printStackTrace();
		}
	
	}
}
